package com.maila.xiaoaoschool.activity;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.maila.xiaoaoschool.R;
import com.zhy.autolayout.AutoLinearLayout;
import com.zhy.autolayout.AutoRelativeLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/10/18.
 */

public class AboutXiaoActivity extends AppCompatActivity {
    @BindView(R.id.white_return_iv)
    AutoRelativeLayout whiteReturnIv;
    @BindView(R.id.tv_shop_namee)
    TextView tvShopNamee;
    @BindView(R.id.ll_title)
    AutoLinearLayout llTitle;
    @BindView(R.id.iv_logo)
    ImageView ivLogo;
    @BindView(R.id.tv_version)
    TextView tvVersion;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);
        ButterKnife.bind(this);
        tvVersion.setText(getVersion());
    }

     public String getVersion() {
       try {
               PackageManager manager = this.getPackageManager();
                PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
             String version = info.versionName;
               return "笑傲Android版_v"+ version+"0";
            } catch (Exception e) {
                 e.printStackTrace();
                  return "笑傲Android版";
               }
        }
    @OnClick({R.id.white_return_iv, R.id.iv_logo})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.white_return_iv:
                finish();
                break;
            case R.id.iv_logo:
                new HideClick().start();
                if (HideClick.sIsAlive >= 9) {
                    Toast.makeText(this, "Maila", Toast.LENGTH_SHORT).show();
                }
        }
    }

        static class HideClick extends Thread {
            public static volatile int sIsAlive = 0;
            @Override
            public void run() {
                sIsAlive++;
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                if (sIsAlive > 0) {
                    sIsAlive--;
                }
                super.run();

            }
        }
}
